import relation from './mapRelation';

class InspectRecord {
    public coor: Coor;
    public name: string;
    public sectionName: string;
    public sectionId: number;
    public imageList: Array<string>;
    constructor() {
        this.coor = new Coor();
    }
    /** 从顺凯的数据格式中进行转换 */
    public static parseFromSkyFormat(item, sectionItem) {
        let record = new InspectRecord();
        record.sectionId = sectionItem.id;
        record.sectionName = sectionItem.name;
        record.coor.lat = item.center.lat;
        record.coor.lon = item.center.lng;
        Object.keys(relation).forEach((sourceKey) => {
            if (typeof item[sourceKey] === 'undefined') return;
            let targetKey = relation[sourceKey];
            let value = item[sourceKey];
            if (Array.isArray(targetKey)) {
                for (let v of targetKey) {
                    record[v] = value;
                }
            } else {
                record[targetKey] = value;
            }
        });
        return record;
    }

}


/** 坐标 */
class Coor {
    public lat: number;
    public lon: number;
}

export default InspectRecord;